<template>
  <div>
    <el-form ref="form" :model="form" label-width="50px">
      <el-form-item label="标题">
        <el-input v-model="form.title"></el-input>
      </el-form-item>
      <el-form-item label="内容">
        <!-- 富文本编辑器 -->
        <vue-editor v-model="content" />
      </el-form-item>
      <el-form-item label="封面">
        <!-- 封面 -->
        <el-upload
          :action="$axios.defaults.baseURL + '/upload'"
          :headers="{
            Authorization: token,
          }"
          list-type="picture-card"
          :on-preview="handlePictureCardPreview"
          :on-success="handleVideoSuccess"
          :on-remove="handleRemove"
        >
          <i class="el-icon-plus"></i>
        </el-upload>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { VueEditor } from "vue2-editor";
export default {
  components: {
    VueEditor,
  },
  data() {
    return {
      form: {
        // 标题
        title: "",
      },
      content: "",
      token: localStorage.getItem("token"),
    };
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      console.log("上传图片", file);
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleVideoSuccess(file) {
      console.log(file);
    },
  },
};
</script>

<style lang="less" scoped>
.el-input {
  width: 200px;
}
</style>
